import React, { Component } from 'react'
import Child from './Child'

export default class Parent extends Component {

    state = {
        hsaError:''
    }

    static getDerivedStateFromError(error){
        console.log(error)
        return {hsaError:error}
    }

    componentDidCatch(){
        console.log('渲染组件时出错')
    }

    render() {
        return (
            <div>
                {this.state.hsaError? <h2>当前网络不稳定...</h2>:<Child />}
                
            </div>
        )
    }
}
